def two_sum(nums, target):
    lookup = {}
    for i, num in enumerate(nums):
        complement = target - num
        if complement in lookup:
            return [lookup[complement], i]
        lookup[num] = i
    return []

# 示例调用
nums = [2, 7, 11, 15]
target = 9
result = two_sum(nums, target)
print("两个数的下标是:", result)
